package com.fzy.Service;

import com.fzy.Dao.EmployeeDao;
import com.fzy.Dao.EmployeeDaoImpl;
import com.fzy.beansa.Employee;

import java.util.ArrayList;
import java.util.List;

public class ServiceImpl implements Service {
    public List<Employee> getAllEmployee() {
        List<Employee> employeelist = new ArrayList<>();
        try {
            EmployeeDao employeedao = new EmployeeDaoImpl();
            employeelist = employeedao.SelectAllEmployee();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return employeelist;
    }

    public int delEmployee(String employeeid) {
        int rs = 0;
        try {
            EmployeeDao employeedao = new EmployeeDaoImpl();
            rs = employeedao.DeleteEmployee(employeeid);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rs;
    }

    public int addEmployee(Employee employee) {
        int rs = 0;
        try {
            EmployeeDao employeedao = new EmployeeDaoImpl();
            rs = employeedao.InsertEmployee(employee);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rs;
    }
}
